To enhance security and prevent users from being locked out when not bringing a key, the users may choose to use electronic locks. A conventional electronic lock may be operated using either touch control operation or the traditional operation using a physical, mechanical key. Such an electronic lock usually includes a lock bolt module, a transmission module to drive the lock bolt module to change between a lock state and an unlock state, a user-input device, and an electric control device communicatively connected to the user-input device and physically connected to the transmission module. The electric control device is configured to cause the transmission module to drive the lock bolt module, and usually has multiple micro switches that can be triggered by the transmission module, so that changing of the state of the lock bolt module may be detected based on the triggering or non-triggering of the micro switches. However, the use of the multiple micro switches may result in problems of space arrangement of elements in the lock and may also incur relatively high cost.